import { request } from '../request';

/** 获取租户列表 */
export function fetchGetTenantList(params?: Api.SystemManage.TenantSearchParams) {
  return request<Api.SystemManage.TenantList>({
    url: '/systemManage/tenant/list',
    method: 'get',
    params
  });
}

/** 获取所有租户 */
export function fetchGetAllTenants() {
  return request<Api.SystemManage.Tenant[]>({
    url: '/systemManage/tenant/all',
    method: 'get'
  });
}

/** 根据ID获取租户详情 */
export function fetchGetTenantById(id: number) {
  return request<Api.SystemManage.Tenant>({
    url: `/systemManage/tenant/${id}`,
    method: 'get'
  });
}

/** 创建租户 */
export function fetchCreateTenant(data: Api.SystemManage.TenantDTO) {
  return request({
    url: '/systemManage/tenant',
    method: 'post',
    data
  });
}

/** 更新租户 */
export function fetchUpdateTenant(id: number, data: Api.SystemManage.TenantDTO) {
  return request({
    url: `/systemManage/tenant/${id}`,
    method: 'put',
    data
  });
}

/** 删除租户 */
export function fetchDeleteTenant(id: number) {
  return request({
    url: `/systemManage/tenant/${id}`,
    method: 'delete'
  });
}

/** 批量删除租户 */
export function fetchBatchDeleteTenants(ids: number[]) {
  return request({
    url: '/systemManage/tenant/batch',
    method: 'delete',
    data: ids
  });
}

/** 检查租户编码是否存在 */
export function fetchCheckTenantCode(tenantCode: string) {
  return request<boolean>({
    url: `/systemManage/tenant/check/${tenantCode}`,
    method: 'get'
  });
}
